package com.yubest.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RoutingTopicConfig {

    @Bean
    public TopicExchange testRoutingTopicExchange() {
        return new TopicExchange("test.routing.topic.exchange");
    }

    @Bean
    public Queue testRoutingTopicQueue1() {
        return new Queue("test.routing.topic.queue1");
    }

    @Bean
    public Queue testRoutingTopicQueue2() {
        return new Queue("test.routing.topic.queue2");
    }

    @Bean
    public Binding testRoutingTopicBinding1() {
        return BindingBuilder.bind(testRoutingTopicQueue1())
                .to(testRoutingTopicExchange()).with("test.routing.topic.key.*");
    }

    @Bean
    public Binding testRoutingTopicBinding2() {
        return BindingBuilder.bind(testRoutingTopicQueue2())
                .to(testRoutingTopicExchange()).with("test.routing.topic.key.#");
    }
}
